<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div {
            width: 600px;
            height: 200px;
            background-color: red;
            font-size: 20px;
            color: white;
            text-align: center;
            line-height: 200px;

        }
    </style>
</head>
<body>
    <div id="time">
        111111111111
    </div>
    <script>
        function showTime(){
            var d = new Date();
            // 格式转化
            // 年
            var year = d.getFullYear();
            // 月
            var month = d.getMonth();  //  0-11   1-12
            // 日
            var date = d.getDate();
            // 时   
            var shi = d.getHours();
            // 分
            var fen = d.getMinutes();
            // 秒
            var miao = d.getSeconds();
            // 星期
            var week = d.getDay(); // 获取星期  返回值是 0-6  其中0代表周日  123456
            var str_week = "";
            switch (week) {
                case 0:
                    str_week = "星期天";
                    break;
                case 1:
                    str_week = "星期一";
                    break;
                case 2:
                    str_week = "星期二";
                    break;
                case 3:
                    str_week = "星期三";
                    break;
                case 4:
                    str_week = "星期四";
                    break;
                case 5:
                    str_week = "星期五";
                    break;
                case 6:
                    str_week = "星期六";
                    break;
                default:
                    break;
            }
            document.getElementById("time").innerHTML = year + "年" + (month+1) + "月" + date + "日 " + str_week + " " + shi + ":" + fen + ":" + miao;
        }

        setInterval("showTime()",1000);


    </script>
</body>
</html>